<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
    <script type="text/javascript" src="__STATIC__/template/lib/html5shiv.js"></script>
    <script type="text/javascript" src="__STATIC__/template/lib/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="__STATIC__/template/static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="__STATIC__/template/static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="__STATIC__/template/lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="__STATIC__/template/static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="__STATIC__/template/static/h-ui.admin/css/style.css" />
    <style>
        /*分页样式*/
        .pagination{text-align:center;margin-top:20px;margin-bottom: 20px;}
        .pagination li{margin:0px 10px; border:1px solid #e6e6e6;padding: 3px 8px;display: inline-block;}
        .pagination .active{background-color: #46A3FF;color: #fff;}
        .pagination .disabled{color:#aaa;}
        a:hover{color: #ff081f; /*鼠标在a上面时,变蓝色*/}

        .groupxx{
            display: none;
        }
        .layer-photos-demo{
            cursor:pointer
        }
    </style>

    <!--[if IE 6]>
    <script type="text/javascript" src="__STATIC__/template/lib/DD_belatedPNG_0.0.8a-min.js" ></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title>用户管理</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
    <span class="c-gray en">&gt;</span> 用户管理
    <span class="c-gray en">&gt;</span> <span style="color:red;">申请提现</span>
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" >
        <i class="Hui-iconfont">&#xe68f;</i>
    </a>
</nav>
<div class="page-container">
    <div class="text-c">
             <span class="select-box" style="width:120px;">
				  <select class="select" id="opt" name="opt">
                      <option value="1" {$opt?($opt ==1 ?'selected = selected':''):''}>提现状态</option>
                      <option value="2" {$opt?($opt ==2 ?'selected = selected':''):''}>申请时间</option>
                      <option value="3" {$opt?($opt ==3 ?'selected = selected':''):''}>提现成功时间</option>
                  </select>
			</span>
            <span class="select-box" style="width:120px;" id="type_s">
				  <select class="select" id="state" name="state">
                      <option value="1" {$state?($state ==1 ?'selected = selected':''):''}>申请提现</option>
                      <option value="2" {$state?($state ==2 ?'selected = selected':''):''}>提现拒绝</option>
                      <option value="3" {$state?($state ==3 ?'selected = selected':''):''}>提现成功</option>
                  </select>
			</span>
        <span id="time" style="display: none">
            <input type="text" value="{$logmin?$logmin:''}" onfocus="WdatePicker({minDate:$('#timeStart').val()})" id="logmin" class="input-text Wdate" style="width:120px;">
            -
            <input type="text" value="{$logmax?$logmax:''}" onfocus="WdatePicker({minDate:$('#timeStart').val()})" id="logmax" class="input-text Wdate" style="width:120px;">
             <input type="text" value="{$phone ? $phone : ''; }" class="input-text" style="width:250px;" placeholder="电话" id="phone" name="phone" >
        </span>
         <button type="submit" class="btn btn-success" onclick="searchUsers()"  name="submit" >
            <i class="icon-search"></i> 搜产品
         </button>

    </div>
    <div class="cl pd-5 bg-1 bk-gray mt-20">
        <span class="r">共有数据：<strong>{$count}</strong> 条</span>
    </div>
    <div class="mt-20">
        <table class="table table-border table-bordered table-hover table-bg table-sort">
            <thead>
            <tr class="text-c">
                <th width="25"><input type="checkbox" name="" value=""></th>
                <th width="80">ID</th>
                <th width="180">用户</th>
                <th width="90">提现金额</th>
                <th width="130">用户目前总金额</th>
                <th width="130">支付宝账号</th>
                <th width="130">申请时间</th>
                <th width="130">交易完成时间</th>
                <th>备注</th>
                <th width="130">状态</th>
                <th width="130">操作</th>
            </tr>
            </thead>
            <tbody>
            {volist name='applies' id='v' empty='$empty'}
            <tr class="text-c">
                <td><input type="checkbox" value="{$v.id}" name=""></td>
                <td>{$v.id}</td>
                <td>
                    <div>{$v.phone}</div>
                </td>
                <td>{$v.amount }</td>
                <td>{$v.commission }</td>
                <td>{$v.ali_account }</td>
                <td>{$v.apply_time|date='Y-m-d',###}</td>
                <td>
                    {notempty name='$v.deal_time'}
                    {$v.deal_time|date='Y-m-d',###}
                    {/notempty}
                </td>
                <td>{$v.remark}</td>
                <td>
                    {if condition='$v.state eq 1'}
                    <span class="label label-danger radius">申请提现</span>
                    {elseif condition='$v.state eq 2'/}
                    <span class="label label-warning radius">申请拒绝</span>
                    {elseif condition='$v.state eq 3'/}
                    <span class="label label-success radius">提现成功</span>
                    {/if}
                </td>
                <td class="td-manage" style="vertical-align:middle">
                    {if condition='$v.state eq 1'}
                    <span class="btn btn-success radius size-MINI" onclick="yes(this,'{$v.id}','{$v.user_id}','{$v.amount}')">通过</span>
                    <span class="btn btn-default radius size-MINI" onclick="no(this,'{$v.id}','{$v.user_id}','{$v.amount}')">拒绝</span>
                    {/if}

                    <a style="text-decoration:none" class="ml-5" onClick="apply_del(this,'{$v.id}')" href="javascript:;" title="删除">
                        <i class="Hui-iconfont">&#xe6e2;</i>
                    </a>
                </td>
            </tr>
            {/volist}
            </tbody>
        </table>
    </div>
    <div class="col-md-8 col-xs-6">{$applies->render()}</div>
</div>


<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="__STATIC__/template/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="__STATIC__/template/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="__STATIC__/template/static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="__STATIC__/template/static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__STATIC__/template/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="__STATIC__/template/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="__STATIC__/template/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">

    $(document).ready(function(){
        $('#opt').change(search_item)
    });
    /* 搜索条件*/
    function search_item(){
        var opt = $('#opt').val();
        if(opt==1){
            $('#time').hide();
            $('#type_s').show();
        }else{
            $('#time').show();
            $('#type_s').hide();
        }
    }

    /*用户-搜索*/
    function searchUsers(){
        var phone  = $('#phone').val();
        var logmin = $('#logmin').val();
        var logmax = $('#logmax').val();
        var opt    = $('#opt').val();
        var state  = $('#state').val();
       // alert(state);
        var url    = "{:url('admin/User/user_apply')}";
        var data   = {
            phone:phone,
            state:state,
            logmin:logmin,
            logmax:logmax,
            opt:opt
        };
        $.post(url,data,function(res){
             console.log(res);
            if(res.ok==false){
                layer.msg(res.msg,{icon:1,time:2000});
            }else{
                $("body").empty();
                $("body").append(res);
                if(opt==1){
                    $('#time').hide();
                    $('#type_s').show();
                }else{
                    $('#time').show();
                    $('#type_s').hide();
                }
            }
        })

    }

    /*申请通过拒绝*/
    function no(obj,id,user_id,amount){
        layer.prompt({
            formType: 0,
            value: '拒绝',
            title: '请输入拒绝理由',
        }, function(value){
            $.post('{:url(\'refuse\')}',{ id:id,value:value,user_id:user_id,amount:amount},function(res){
                console.log(res);
                if(res.ok){
                    layer.msg('修改成功！',{icon:1,time:1000});
                    setTimeout("window.location.replace(location.href)",1000);
                }else{
                    layer.msg('修改失败！',{icon:5,time:1000});
                }
            })
            layer.close(index);
        });
    }

    /*申请通过*/
    function yes(obj,id,user_id,amount){
        layer.prompt({
            formType: 0,
            value: '提现成功，请在您的支付宝中查看详情',
            title: '请输入通过信息',
        }, function(value,index){
            $.post('{:url(\'adopt\')}',{ id:id,value:value,user_id:user_id,amount:amount},function(res){
                console.log(res);
                if(res.ok){
                    layer.msg('修改成功！',{icon:1,time:1000});
                    setTimeout("window.location.replace(location.href)",1000);
                }else{
                    layer.msg('修改失败！',{icon:5,time:1000});
                }
            })
            layer.close(index);
        });
    }
    function apply_del(obj,id){
        layer.confirm('确认要放入回收站吗？',function(index){
            $.ajax({
                type: 'POST',
                url: '{:url(\'apply_del\')}',
                data: { id:id },
                dataType: 'json',
                success: function(data){
                    console.log(data);
                    if(data.ok){
                        $(obj).parents("tr").remove();
                        layer.msg(data.msg,{icon:1,time:1000});
                    }else{
                        layer.msg(data.msg,{icon:2,time:1000});
                    }
                },
                error:function(data) {
                    if(data.ok==false){
                        layer.msg(data.msg,{icon:2,time:1000});
                    }
                    console.log(data.msg);
                },
            });
        });
    }
</script>
</body>
</html>